package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/stu/showStudentServlet")
public class ShowStudentServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StringBuffer requestURL = req.getRequestURL();
        System.out.println(requestURL);
        BufferedReader br = new BufferedReader(new FileReader("D:\\heimastudy\\AdvanceStudent\\WebDemo05\\src\\info.txt"));
        PrintWriter pw = resp.getWriter();
        String len;
        while ((len=br.readLine())!=null){
            pw.write(len+"<br/>");
        }
        br.close();
        pw.close();
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
